<%--登录界面--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>请登陆</title>
    <link rel="stylesheet" href="resources/css/bootstrap.min.css">
    <link href="resources/css/login.css" type="text/css" rel="stylesheet" />
</head>
<body>
<%
    String un="";
    String pwd="";
    Cookie[] cookies=request.getCookies();
    if(cookies!=null){
        for(Cookie cookie:cookies){
            if(cookie.getName().equals("name")){
                un=cookie.getValue();
            }
            if(cookie.getName().equals("password")){
                pwd=cookie.getValue();
            }
//            System.out.println(un+":"+pwd);
        }
    }
%>
<script>
    function check(form){
        if (form.user.value === "") {
            alert("请输入账号！");
            return false;
        }
        if (form.password.value === "") {
            alert("请输入密码！");
            return false;
        }
        return true;
    }
</script>
<div class="center">
    <h1 class="text-center">欢迎来到学校教务系统</h1>
    <div class="main">
        <h5 class="title">
            <a href="login.jsp" id="login">登录</a>
            &nbsp;& &nbsp;
            <a href="register.jsp" id="register">注册</a>
        </h5>
        <form action="check_login" method="post" onsubmit="return check(this)">
            <div class="form-group">
                <input type="text" name="user" class="form-control user" value="<%=un%>" placeholder="请输入用户名">
                <input type="password" name="password" class="form-control password" value="<%=pwd%>" placeholder="请输入密码">

                <div class="form-check form-check-inline"  style="margin-left: -50px">
                    <input name="role" id="teacher" type="radio" value="teacher" checked class="form-check-input">
                    <label class="form-check-label" for="teacher">教师</label>
                </div>
                <div class="form-check form-check-inline"  style="margin-left: 30px">
                    <input name="role" id="student" type="radio" value="student" class="form-check-input">
                    <label class="form-check-label" for="student">学生</label>
                </div>

                <div class="remember-btn">
                    <input type="checkbox" id="remember" name="remember" value="true">
                    <label for="remember">记住我</label>
                </div>
                <a href="forget.jsp" class="help">忘记密码？</a>
                <input type="submit" value="登录" class="btn btn-primary btn-lg btn-block" />
            </div>
        </form>
    </div>
</div>

<%-- 先引入jquery的js文件 --%>
<script src="resources/js/jquery-3.2.1.min.js"></script>
<script src="resources/js/popper.min.js"></script>
<script src="resources/js/bootstrap.min.js"></script>
</body>
</html>